﻿<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    xmlns:mr2="http://www.wales.nhs.uk/namespaces/MessageRelease2"
>
  <xsl:output version="4.0" method="html" indent="no"  omit-xml-declaration="yes" encoding="UTF-8" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
  <xsl:template match="//GetDocumentResponse">
    <table id="history" class="selectable">
      <thead>
        <tr>
          <th>Version Description</th>
          <th>Author</th>
          <th>Creation Date</th>
          <th>Revoked</th>
          <th>Sensitive</th>
        </tr>
      </thead>
      <tbody>
        <xsl:for-each select="mr2:Document/mr2:History/mr2:DocumentVersionHeader">
          <xsl:variable name="documentid" select="mr2:DocumentId"/>
          <xsl:variable name="sensitive" select="mr2:SensitivityTypeCode"/>
          <tr class="document" documentid='{$documentid}' sensitive='{$sensitive}'>
            <td>
              <xsl:value-of select="mr2:VersionDescription"/>
            </td>
            <td>
              <xsl:value-of select="mr2:DocumentAttribute[mr2:Attribute='Author']/mr2:Value"/>
            </td>
            <td>
              <xsl:value-of select="msxsl:format-date(mr2:DocumentDateTime, 'MMM dd, yyyy')"/> (<xsl:value-of select="msxsl:format-time(mr2:DocumentDateTime, 'hh:mm')"/>)
            </td>
            <td>
              <xsl:value-of select="mr2:Revoked"/>
            </td>
            <td>
              <xsl:choose>
                <xsl:when test="mr2:SensitivityTypeCode = '0'">false</xsl:when>
                <xsl:otherwise>true</xsl:otherwise>
              </xsl:choose>
            </td>
          </tr>
        </xsl:for-each>
      </tbody>
    </table>
  </xsl:template>
</xsl:stylesheet>

